<html>
<head>
<style type='text/css'>
body {
   background-color: white;
   margin: 1em 2em 1em 2em;
   font-family: Sans-Serif;
   color: #002;
   line-height: 140%;
   font-size: 12px;
}

h1 {
    font-size: 140%;
}

h2 {
    font-size: 130%;
}

h3 {
    font-size: 120%;
}

h4 {
    font-size: 100%;
    font-style: normal;
    font-weight: bold;
}

h5 {
    font-size: 100%;
    font-style: italic;
    font-weight: normal;
}

pre {
   background-color: #eee;
   padding: 0.5em 0.5em 0.5em 2em;
}

@media print {
   pre {word-wrap:break-word; width:100%;}
} 

ul li,
ol li {
   padding-left: 0.3em;
   /*text-indent: -2em;*/
   margin-bottom: 0.5em;
}

em {
   font-style: normal;
   font-weight: bold;
   text-decoration: underline;
   color: #c40;
}

code {
   font-family: Monospace;
   font-size: 100%;
   color: #c40;
}

a, a * {
   text-decoration: underline;
   color: blue;
   /* border: 0.5px solid #aaa;
   white-space: nowrap;
   padding-right: 0.1em;
   padding-left: 0.1em;
   padding-bottom: -5px; */
}

a code {
   color: blue;
}

img {
   position: relative;
   bottom: -4px;
}

div.headline {
   font-weight: bold;
   font-size: 110%;
}

div.copyright {
   margin-top: 1em;
   border-top: 1px solid black;
   padding-top: 0.5em;
}

div.iris_headline {
   border-bottom: 1px solid black;
   padding-bottom: 0.3em;
}

.LaTeX {
   font-family: Monospace;
   font-size: 100%;
   border: 1px solid #060;
   color: #060;
}

code.LaTeX {
   background-color: white;
   padding: 0.5em 0.5em 0.5em 2em;
}
</style>
</head>

<body>
<div class="iris_headline">IRIS Toolbox Reference Manual</div>




<h2 id="model/loglik">loglik</h2>
<div class="headline">Evaluate minus the log-likelihood function in time or frequency domain</div>

<h4 id="full-syntax">Full syntax</h4>
<pre><code>[Obj,V,F,PE,Delta,PDelta] = loglik(M,D,Range,...)</code></pre>
<h4 id="syntax-for-fast-one-off-likelihood-evaluation">Syntax for fast one-off likelihood evaluation</h4>
<pre><code>Obj = loglik(M,D,Range,...)</code></pre>
<h4 id="syntax-for-repeated-fast-likelihood-evaluations">Syntax for repeated fast likelihood evaluations</h4>
<pre><code>% Step #1: Initialise.
loglik(M,D,Range,...,&#39;persist=&#39;,true);

% Step #2: Assign/change parameters.
M... = ...; % Change parameters.

% Step #3: Re-compute steady state and solution if necessary.
M = ...;
M = ...;

% Step #4: Evaluate likelihood.
L = loglik(M);

% Repeat steps #2, #3, #4 for different values of parameters.
% ...</code></pre>
<h4 id="input-arguments">Input arguments</h4>
<ul>
<li><p><code>M</code> [ model ] - Model object on which the likelihood of the input data will be evaluated.</p></li>
<li><p><code>D</code> [ struct | cell ] - Input database or datapack from which the measurement variables will be taken.</p></li>
<li><p><code>Range</code> [ numeric ] - Date range.</p></li>
</ul>
<h4 id="output-arguments">Output arguments</h4>
<ul>
<li><p><code>Obj</code> [ numeric ] - Value of minus the log-likelihood function (or other objective function if specified in options).</p></li>
<li><p><code>V</code> [ numeric ] - Estimated variance scale factor if the <code>'relative='</code> options is true; otherwise <code>V</code> is 1.</p></li>
<li><p><code>F</code> [ numeric ] - Sequence of forecast MSE matrices for measurement variables.</p></li>
<li><p><code>PE</code> [ struct ] - Database with prediction errors for measurement variables; exp of prediction errors for measurement variables declared as log-variables.</p></li>
<li><p><code>Delta</code> [ struct ] - Databse with point estimates of the deterministic trend parameters specified in the <code>'outoflik='</code> option.</p></li>
<li><p><code>PDelta</code> [ numeric ] - MSE matrix of the estimates of the <code>'outoflik='</code> parameters.</p></li>
</ul>
<h4 id="options">Options</h4>
<ul>
<li><p><code>'objDecomp='</code> [ <code>true</code> | <em><code>false</code></em> ] - Decompose the objective function into the contributions of individual time periods (in time domain) or individual frequencies (in frequency domain); the contributions are added as extra rows in the output argument <code>Obj</code>.</p></li>
<li><p><code>'persist='</code> [ <code>true</code> | <em><code>false</code></em> ] -- Pre-process and store the overhead (data and options) for subsequent fast calls.</p></li>
</ul>
<p>See help on <a href="../model/filter.html"><code>model/filter</code></a> for other options available.</p>
<h4 id="description">Description</h4>
<p>The number of output arguments you request when calling <code>loglik</code> affects computational efficiency. Running the function with only the first output argument, i.e. the value of the likelihood function (minus the log of it, in fact), results in the fastest performance.</p>
<p>The <code>loglik</code> function runs an identical Kalman filter as <a href="../model/filter.html"><code>model/filter</code></a>, the only difference is the types and order of output arguments returned.</p>
<h5 id="fast-evaluation-of-likelihood">Fast evaluation of likelihood</h5>
<p>Every time you change the parameters, you need to update the steady state and solution of the model if necessary by yourself, before calling <code>loglik</code>. Follow these rules:</p>
<ul>
<li><p>If you only change std deviations and no other parameters, you don't have to re-calculate steady state or solution.</p></li>
<li><p>If the model is linear, you only need to call <a href="../model/solve.html"><code>solve</code></a>.</p></li>
<li><p>The only exception to rules #2 and #3 is when the model has <a href="../modellang/links.html"><code>dynamic links</code></a> with references to some steady state values. In that case, you must also run <a href="../model/sstate.html"><code>sstate</code></a> after <a href="../model/solve.html"><code>solve</code></a> in linear models to update the steady state.</p></li>
<li><p>If the model is non-linear, and you only change parameters that affect transitory dynamics and not the steady state, you only need to call <a href="../model/solve.html"><code>solve</code></a>.</p></li>
<li><p>If the model is non-linear, and you change parameters that affect both transitory dynamics and steady state, you must run first <a href="../model/sstate.html"><code>sstate</code></a> and then <a href="../model/solve.html"><code>solve</code></a>.</p></li>
</ul>
<h4 id="example">Example</h4>

</body>
<div class="copyright">IRIS Toolbox. Copyright &copy; 2007-2014 Jaromir Benes.</div>
</html>
